#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main()
{
    umask(0);
    int fd = open("log.txt", O_RDONLY,0666);
    if(fd < 0)
   {
       printf("open file error\n");
       return 1;
   }

    char message[128];//自定义缓冲区
    ssize_t poi =read(fd,message,sizeof(message)-1);//预留\0的位置
    if(poi==-1)
    {
        perror("read");
        return -1;
    }
    message[poi] = 0;
    printf("%s",message);

    close(fd);
    return 0;
}